package com.tjtt.tdm.system.service.impl;

import java.io.IOException;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.exception.DaoException;
import com.tjtt.tdm.exception.ServiceException;
import com.tjtt.tdm.system.bean.SysCerify;
import com.tjtt.tdm.system.dao.CerifyDao;
import com.tjtt.tdm.system.service.CerifyService;

public class CerifyServiceImpl implements CerifyService {
	private static final Log log = LogFactory.getLog(CerifyServiceImpl.class);
	private CerifyDao cerifyDao;

	/**
	 * 删除证书
	 * @throws IOException
	 * @throws ServiceException void
	 * @author 
	 * @date
	 */
	public void deleteCerity(String ids) {
		String idss[] = ids.split(",");
		for (String id : idss) {
			SysCerify sysCerify=new SysCerify();
			sysCerify.setId(Long.parseLong(id));
		this.cerifyDao.deleteCerity(sysCerify);
		}
	}

	/**
	 * 保存用户里证书的信息
	 * @return
	 * @throws IOException
	 * @throws ServiceException
	 */
	public void saveCerify(SysCerify sysCerify) throws ServiceException {
		try {
			cerifyDao.save(sysCerify);
		} catch (DaoException e) {
			throw new ServiceException(e.getMessage(),e);
		}
	}
	/**
	 * 查询所有证书
	 * @throws Exception
	 */
	public PageResult querycerifyInfo(Map<String, String> filterMap,String userid) {
		return this.cerifyDao.querycerifyInfo(filterMap,userid);
	}
	
	
	public SysCerify findSysCerifyById(long id) {
		return this.cerifyDao.findCerityById(id);
	}

	
	public CerifyDao getCerifyDao() {
		return cerifyDao;
	}

	public void setCerifyDao(CerifyDao cerifyDao) {
		this.cerifyDao = cerifyDao;
	}

	/**
	 * 修改用户里证书的信息
	 * @return
	 * @throws IOException
	 * @throws ServiceException
	 */
	public void updateCerify(SysCerify sysCerify) throws ServiceException {
		try {
			cerifyDao.saveOrUpdate(sysCerify);
		} catch (DaoException e) {
			throw new ServiceException(e.getMessage(),e);
		}
	}

	public SysCerify checkOneCerifyById(Long id) {
		return this.cerifyDao.checkOneCerifyById(id);
	}


	

}